SET SERVEROUTPUT ON;
create or replace procedure CURSORSAMPLE
AS

id	char(20);
fname	char(20);
lname	char(20);

cursor stuCursor is
	select stuid, firstname, lastname
	from student;

begin
	open stuCursor;
	LOOP		
		fetch stuCursor into id, fname, lname;
		DBMS_OUTPUT.PUT_LINE(id || '   '||fname||' '||lname);
	exit when stuCursor%notfound;
	END LOOP;
	close stuCursor;


exception
	when no_data_found then 
		DBMS_OUTPUT.PUT_LINE('No data found');
	when others then
		DBMS_OUTPUT.PUT_LINE('Error-' || SQLERRM);

END;

/
